<?
	require_once('init.php');
	require_once('dataModel.php');
	if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
	{
		$h_tourl="login.php";
		header("Location:".$h_tourl);
		exit;
	}
	$SeasonID=$_GET['ID'];
	$Type=$_GET['Type'];
	$pgno=$_GET['pgno'];
    
    if ($Type==0)
    {
    	$Title="新增季别资料";
		$strSQL = "select * from season where 1=0";
		$imtype="0";
	}
    else if ($Type==1)
    {
    	$Title="修改季别资料";
		$strSQL = "select * from season where id='".$SeasonID."' ";
    }

	$db = MySQL::getInstance('','r-w'); 
	$DBR=$db->query($strSQL); 
  	$result=$db->fetch($DBR);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=<?='utf-8';?>" />
	<title><?=$AllPageTitle;?></title>
	<link href="css/CenterMenu.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" href="css/Buttonstyle.css" type="text/css" media="screen" />	
	
	<? include("alljs.php"); ?>
	
	<script language="javascript">
		function goback(pgno)
		{
			self.location='seasonmanager.php?pgno='+pgno
		}

		function CheckData()
		{
			value = $("#seasonname").attr("value");
	       	if( value=="")
	       	{
				parent.hiAlert("请输入季别!", '系统提示');
				$("#seasonname").focus();
				return false;
	        }

			value = $("#seasonname_e").attr("value");
	       	if( value=="")
	       	{
				parent.hiAlert("请输入季别(英文)!", '系统提示');
				$("#seasonname_e").focus();
				return false;
	        }

			var strSQL = "";                      
			strSQL+= "&seasonname=";
			strSQL+=$("#seasonname").attr("value");
			strSQL+= "&seasonname_e=";
			strSQL+=$("#seasonname_e").attr("value");
			strSQL+= "&remark=";
			strSQL+=$("#remark").attr("value");
			strSQL+= "&Type=AddSeason";
			
//			alert (strSQL);
			
			$.post("varifyData.php",strSQL,function(msg)
			{

//			    alert (msg);
			    
			   	if (msg=='1')
			   	{	
					parent.hiAlert("数据保存成功!", '系统提示');
					
					$("#seasonname").attr("value","");
					$("#seasonname_e").attr("value","");
					$("#remark").attr("value","");

					$("#seasonname").focus();
					return false;
			   	}
			})
	        
		}

   		function CheckDataEdit(EID)
   		{
			value = $("#seasonname").attr("value");
	       	if( value=="")
	       	{
				parent.hiAlert("请输入季别!", '系统提示');
				$("#seasonname").focus();
				return false;
	        }

			value = $("#seasonname_e").attr("value");
	       	if( value=="")
	       	{
				parent.hiAlert("请输入季别(英文)！", '系统提示');
				$("#seasonname_e").focus();
				return false;
	        }

			var strSQL = "";                      
			strSQL+= "&EID="+EID;
			strSQL+= "&seasonname=";
			strSQL+=$("#seasonname").attr("value");
			strSQL+= "&seasonname_e=";
			strSQL+=$("#seasonname_e").attr("value");
			strSQL+= "&remark=";
			strSQL+=$("#remark").attr("value");
			strSQL+= "&Type=EditSeason";
			
//			alert (strSQL);
			
			$.post("varifyData.php",strSQL,function(msg)
			{

//			    alert (msg);
			    
			   	if (msg=='1')
			   	{	
					parent.hiAlert("数据保存成功!", '系统提示');
					self.location="seasonmanager.php";
					//$("#seasonname").focus();
					//return false;
			   	}
			})
	        
	    }    
	</script>
</head>


<body>
	<div id="MenuRighttitle" ><div style="padding-left:245px;padding-top:5px;"><b><?=$Title;?></b></div></div>

	<div class="inner-container">
		<div class="bodypart" style="border:0px solid blue;">	
			<div style="padding-left: 10px; margin-top: 20px; text-align: left; height:auto;border:0px solid blue;">

				<div class="coloraddnew_a01"><?="季别:";?></div>
				<div class="coloraddnew_a02" ><input type="text" id="seasonname" name="seasonname" value="<?=$result["season"];?>" size="30" maxlength="20" class="goodsaddnew_textbox" style="width:280px;" /></div>

				<div class="coloraddnew_a01"><?="季别(英文):";?></div>
				<div class="coloraddnew_a02" ><input type="text" id="seasonname_e" name="seasonname_e" value="<?=$result["season_e"];?>" size="30" maxlength="20" class="goodsaddnew_textbox" style="width:280px;" /></div>

				<div class="coloraddnew_a01"><?="备注:";?></div>
				<div class="coloraddnew_a02" ><input type="text" id="remark" name="remark" value="<?=$result["remark"];?>" size="30" maxlength="20" class="goodsaddnew_textbox" style="width:280px;" /></div>

				<div class="coloraddnew_a01" style="margin-top: 50px;width:700px;text-align:center;border:0px solid blue;">
					<?
					if ($Type==0)
					{
					?>
						<input type="image" name="image" value="image" src="images/submit_btn.gif" onclick="javascript:CheckData();" /> 
					<?
					}
					else if ($Type==1)
					{
					?>
						<input type="image" name="image" value="image" src="images/submit_btn.gif" onclick="javascript:CheckDataEdit('<?=$result["id"];?>');" />
					<?
					}
					?>


					<input type="image" name="image" value="image" src="images/go_btn.gif" onclick="javascript:goback('<?=$pgno;?>');" /> 
				</div>
			</div>
		</div>
	</div>
</body>

</html>
